/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package desarrollosoft.ghce.dao.implementaciones;

import desarrollosoft.ghce.dao.interfaces.IIntervencionDAO;
import desarrollosoft.ghce.entidades.Intervencion;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author ariel
 */
@Repository("intervencionDAO")
public class IntervencionDAO implements IIntervencionDAO {

    @PersistenceContext
    EntityManager entityManager;
    
    @Override
    @Transactional(propagation = Propagation.MANDATORY)
    public void crearIntervencion(Intervencion intervencion) throws Exception {
        entityManager.persist(intervencion);
    }

    @Override
    @Transactional(propagation = Propagation.MANDATORY)
    public void modificarIntervencion(Intervencion intervencion) throws Exception {
        entityManager.merge(intervencion);
    }

    @Override
    @Transactional(propagation = Propagation.MANDATORY)
    public void eliminarIntervencion(Intervencion intervencion) throws Exception {
        entityManager.remove( entityManager.merge(intervencion) );
    }
    
}
